Skip to content

system-reinstall-bootc: fallback image from /usr/lib/os-release#2135

Open
hone wants to merge 5 commits intobootc-dev:mainfrom
hone:default-image-os-release
Open

system-reinstall-bootc: fallback image from /usr/lib/os-release#2135
hone wants to merge 5 commits intobootc-dev:mainfrom
hone:default-image-os-release

Conversation

@hone
Copy link
Copy Markdown
Contributor

@hone hone commented Apr 9, 2026

Add a fallback option when arguments are specified for an image. It works in this order:

  1. BOOTC_REINSTALL_CONFIG env var to a YAML file
  2. --image flag
  3. reads /etc/os-release for BOOTC_IMAGE
  4. reads /usr/lib/os-release for BOOTC_IMAGE

Fixes: #1300

Add a fallback option when arguments are specified for an image. It
works in this order:
  1. BOOTC_REINSTALL_CONFIG env var to a YAML file
  2. `--image` flag
  3. reads /etc/os-release for BOOTC_IMAGE
  4. reads /usr/lib/os-release for BOOTC_IMAGE

Fixes: bootc-dev#1300

Signed-off-by: Terence Lee <hone02@gmail.com>
@github-actions github-actions bot added the area/system-reinstall-bootc Issues related to system-reinstall-botoc label Apr 9, 2026
@hone hone marked this pull request as draft April 9, 2026 16:53
@bootc-bot bootc-bot bot requested a review from jmarrero April 9, 2026 16:53
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a fallback mechanism to retrieve the bootc image from os-release files when not specified via CLI or environment variables. The changes include a new parsing module, refactored argument handling, and updated CI scripts. Feedback suggests parsing CLI arguments earlier to support standard flags like --help, filtering empty strings during os-release lookups for better fallback reliability, and consolidating redundant CI steps.

Comment on lines +28 to +39
order: 97
script:
- mkdir -p bootc && cp /var/share/test-artifacts/*.src.rpm bootc
- cd bootc && rpm2cpio *.src.rpm | cpio -idmv && rm -f *-vendor.tar.zstd && zstd -d *.tar.zstd && tar -xvf *.tar -C . --strip-components=1 && ls -al
- pwd && ls -al && cd bootc/hack && ./provision-packit.sh
when: running_env != image_mode
- how: shell
order: 98
script:
- echo 'BOOTC_IMAGE=localhost/bootc' | tee -a /usr/lib/os-release
- pwd && ls -al && cd bootc/hack && ./provision-packit.sh
when: running_env != image_mode
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These two shell steps are redundant and inefficient. Both steps perform the same setup and run provision-packit.sh, which includes a time-consuming podman build operation. Since provision-packit.sh is already designed to handle both the explicit argument and the os-release fallback, you should combine these into a single step to avoid rebuilding the image and repeating the setup in CI.

    order: 97
    script:
      - mkdir -p bootc && cp /var/share/test-artifacts/*.src.rpm bootc
      - cd bootc && rpm2cpio *.src.rpm | cpio -idmv && rm -f *-vendor.tar.zstd && zstd -d *.tar.zstd && tar -xvf *.tar -C . --strip-components=1 && ls -al
      - pwd && ls -al && cd bootc/hack && ./provision-packit.sh
      - echo 'BOOTC_IMAGE=localhost/bootc' | tee -a /usr/lib/os-release
      - ./provision-packit.sh
    when: running_env != image_mode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was easier to just build the image twice than try to do a cleanup step for testing the BOOTC_IMAGE path on reinstall.

If cloud-init is detected in the target image:
1. Check the host for existing root SSH keys at /root/.ssh/authorized_keys.
2. If host keys exist, automatically configure inheritance via
   /target/root/.ssh/authorized_keys.
3. If no host keys exist, proceed without manual interaction, trusting
   cloud-init in the new system to handle key provisioning.

If cloud-init is not detected, maintain the existinginteractive behavior
to prevent user lock-out.

Ref: bootc-dev#1300

Signed-off-by: Terence Lee <hone02@gmail.com>
@hone
Copy link
Copy Markdown
Contributor Author

hone commented Apr 9, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to automatically detect the bootc image from os-release files (/etc/os-release or /usr/lib/os-release) if not provided via the CLI. It also adds logic to automatically inherit host SSH keys when cloud-init is detected in the target image. Key changes include a new os_release module for parsing, updates to the CLI argument handling, and integration test adjustments. Feedback highlights a critical path error where a container-internal path is used as a host path for SSH key inheritance, potential inefficiencies and failures in the updated test plan, and an opportunity to refactor the image resolution logic for better maintainability.

Signed-off-by: Terence Lee <hone02@gmail.com>
@hone hone force-pushed the default-image-os-release branch from 5bb1c1e to ee263a3 Compare April 9, 2026 22:43
hone added 2 commits April 9, 2026 23:02
Signed-off-by: Terence Lee <hone02@gmail.com>
Signed-off-by: Terence Lee <hone02@gmail.com>
@hone hone marked this pull request as ready for review April 10, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/system-reinstall-bootc Issues related to system-reinstall-botoc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for default image from /usr/lib/os-release or so

1 participant